package com.bosssoft.hr.train.j2se.file;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

/**
 * OssFileUitls
 */
public class OssFileUitls {
    /**
     * update 实现文件上传
     * @param file 上传的文件
     * @throws IOException
     */
    public void update(MultipartFile file) throws IOException {
        String fileName = file.getName();
        fileName = UUID.randomUUID()+"_"+fileName;
        String path ="F:/file/";
        File filePath = new File(path);
        if (!filePath.exists()){
            filePath.mkdirs();
        }
        try{
            file.transferTo(new File(fileName));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
